﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SzCourt.Logic.BLL;
using SzCourt.Logic.NBL.DBEntities;

namespace SzCourt.WebSite.manager
{
    public partial class shoulifangwei : System.Web.UI.Page
    {
        private string _RangeContent = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!AdminSession.SessionBox.CheckUserSession())
            {
                Response.Redirect("/manager/login.aspx");
            }
            if (!this.IsPostBack)
            {
                this._RangeContent = string.IsNullOrEmpty(Request.Form["txtRangeContent"]) ? "" : Request.Form["txtRangeContent"];
                if (this._RangeContent.Length > 0)
                {
                    EditInfo();
                }
                else
                {
                    getInfo();
                }
            }
        }

        /// <summary>
        /// 获取案件受理范围
        /// </summary>
        private void getInfo()
        {
            CaseAccepRangeParam param = new CaseAccepRangeParam();
            param.CaseType = CaseTypes.MinShi;

            PreCase bll = new PreCase();
            pPreCaseAccepRange result = (pPreCaseAccepRange)bll.GetAccepRangeInfo(param);

            if (result != null)
            {
                this.txtRangeContent.Value = result.RangeContent;
            }

        }

        /// <summary>
        /// 修改案件受理范围
        /// </summary>
        private void EditInfo()
        {
            CaseAccepRangeParam param = new CaseAccepRangeParam();
            param.CaseType = CaseTypes.MinShi;
            param.RangeContent = this._RangeContent;
            PreCase bll = new PreCase();
            bool result = (bool)bll.EditCaseAccepRange(param);

            if (result)
            {
                this.divMessages.InnerHtml = "修改成功！";
            }
            else
            {
                this.divMessages.InnerHtml = "修改失败！";
            }

        }
    }
}